package com.woniuxy.swagger.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.Collections;

/**开启swagger3
 * 访问测试 http://localhost:8080/swagger-ui/index.html
 * */
@EnableOpenApi
@Configuration
@EnableKnife4j

public class SwaggerConfiguration {
    /**
     *
     * Swagger实例Bean是Docket
     * RequestHandlerSelectors.any() 扫描接口的方式:针对所有接口都不过滤
     * PathSelectors.any()).build() 针对所有路径都支持
     * @return
     */
    @Bean
    public Docket api(){
        return new Docket(DocumentationType.OAS_30).select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any()).build()
                .apiInfo(apiInfo());
    }

    /**
     * 配置文档信息 apiInfo
     * 设置项目描述
     * @return
     */

    @Bean
    public ApiInfo apiInfo(){
        return new ApiInfo("考试系统项目",
                "该项目主要介绍：Swagger的应用，以及RestTemplate的使用",
                "V1.0",
                "接口技术支持",
                new Contact("后端2组","http://woniuxy.com/","565599455@qq.com"),
                "营业执照","http://woniuxy.com/",
                Collections.emptyList());
    }
}
